package fiuba.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

@Entity
public class DetalleEstructura extends BaseObject implements Comparable<DetalleEstructura> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3679277407454034620L;
	private Long id;
	private Integer rowStart;
	private Integer colStart;
	private Integer colSpan;
	private String backgroundColor;
	private String textColor;
	private String vAlign;
	private String hAlign;
	
	private Estructura estructura;
	private Contenedor contenedor;
	

	@Override
	public boolean equals(Object o) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return null;
	}
	@Column
	public Integer getRowStart() {
		return rowStart;
	}

	public void setRowStart(Integer rowStart) {
		this.rowStart = rowStart;
	}
	@Column
	public Integer getColStart() {
		return colStart;
	}

	public void setColStart(Integer colStart) {
		this.colStart = colStart;
	}
	@Column
	public Integer getColSpan() {
		return colSpan;
	}

	public void setColSpan(Integer colSpan) {
		this.colSpan = colSpan;
	}
	@ManyToOne
    @JoinColumn(name="estructura_fk")
	public Estructura getEstructura() {
		return estructura;
	}

	public void setEstructura(Estructura estructura) {
		this.estructura = estructura;
	}
	@Id @GeneratedValue(strategy = GenerationType.AUTO) 
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	
	// Comparador para ordenar
	public int compareTo(DetalleEstructura d){
    	if (this.getRowStart().compareTo(d.getRowStart()) != 0) {
    		return this.getRowStart().compareTo(d.getRowStart());
    	}
    	if (this.getColStart().compareTo(d.getColStart()) != 0) {
    		return this.getColStart().compareTo(d.getColStart());
    	}
    	return 0;
	}

	@Column(length=10)
	public String getBackgroundColor() {
		return backgroundColor;
	}

	public void setBackgroundColor(String backgroundColor) {
		this.backgroundColor = backgroundColor;
	}

	@Column(length=10)
	public String getVAlign() {
		return vAlign;
	}

	public void setVAlign(String align) {
		vAlign = align;
	}

	@Column(length=10)
	public String getHAlign() {
		return hAlign;
	}

	public void setHAlign(String align) {
		hAlign = align;
	}
	@Column(length=10)
	public String getTextColor() {
		return textColor;
	}

	public void setTextColor(String textColor) {
		this.textColor = textColor;
	}

	@OneToOne
    @JoinColumn(name="contenedor_fk")
	public Contenedor getContenedor() {
		return contenedor;
	}

	public void setContenedor(Contenedor contenedor) {
		this.contenedor = contenedor;
	}
	
}
